package com.lk.base.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DateUtil {

	public interface DatePattern{
		public static final String MM_dd = "MM-dd";
		public static final String HHmmss = "HH:mm:ss";
		public static final String yyyy_MM_dd = "yyyy-MM-dd";
		public static final String yyyy_MM_ddHH = "yyyy-MM-dd HH";
		public static final String yyyy_MM_ddHHmm = "yyyy-MM-dd HH:mm";
		public static final String yyyy_MM_ddHHmmss = "yyyy-MM-dd HH:mm:ss";
	}

	static SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public static String yearMonthAddZero(String date) {
		StringBuffer sb = new StringBuffer();
		String arr[] = date.split("-");
		sb.append(arr[0]);
		sb.append("-");
		sb.append(arr[1].length() == 1 ? "0" + arr[1] : arr[1]);
		sb.append("-");
		sb.append(arr[2].length() == 1 ? "0" + arr[2] : arr[2]);
		return sb.toString();
	}

	public static String formatDate(Date date,String pattern) {
		if(date == null) {
			return "";
		}
		try {
			SimpleDateFormat sdf=new SimpleDateFormat(pattern);
			String format = sdf.format(date);
			return format;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}
	public static String formatDate(Date date) {
		return formatDate(date, DatePattern.yyyy_MM_ddHHmmss);
	}
	public static Date parseDate(String dateStr,String pattern) {
		if(dateStr == null) {
			return null;
		}
		try {
			SimpleDateFormat sdf=new SimpleDateFormat(pattern);
			Date format = sdf.parse(dateStr);
			return format;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	public static Date parseDate(String dateStr) {
		if(dateStr == null) {
			return null;
		}
		try {

			Date format = sdf1.parse(dateStr);
			return format;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	public static String getCurrentTime() {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar c = Calendar.getInstance();
		return sf.format(c.getTime());
	}
	public static String getCurrentDate() {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		return sf.format(c.getTime());
	}

	public static Date addNDay(Date date,int day) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.DAY_OF_MONTH, day);
		return c.getTime();
	}
	public static Date addNHour(Date date,int hour) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.HOUR_OF_DAY, hour);
		return c.getTime();
	}
	public static Date addNMinute(Date date,int minute) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.MINUTE, minute);
		return c.getTime();
	}
	public static Date addNSecond(Date date,int second) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.SECOND, second);
		return c.getTime();
	}

	public static String afterNHour(Date date,int hour) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.HOUR_OF_DAY, hour);
		return sf.format(c.getTime());
	}
	public static String afterNMinute(Date date,int minute) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.MINUTE, minute);
		return sf.format(c.getTime());
	}

	public static String afterNDay(Date date,int day) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.DAY_OF_MONTH, day);
		return sf.format(c.getTime());
	}
	public static String afterNDay(int day) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DAY_OF_MONTH, day);
		return sf.format(c.getTime());
	}

	public static String beforeNDay(int day) {
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DAY_OF_MONTH, -day);
		return sf.format(c.getTime());
	}

	public static String calcTaskTime(Date startTime, List<String> times, int hours) {

		Calendar calendar = Calendar.getInstance();
		calendar.setTime(startTime);					//放入Date类型数据

		int year = calendar.get(Calendar.YEAR);					//获取年份
		int month = calendar.get(Calendar.MONTH) + 1;					//获取月份
		int day = calendar.get(Calendar.DATE);					//获取日

		int hour = calendar.get(Calendar.HOUR_OF_DAY);				//时（24小时制）
		int minute = calendar.get(Calendar.MINUTE);					//分
		int second = calendar.get(Calendar.SECOND);

		Map<String,Integer> current = new HashMap<>();
		current.put("a", 0);
		current.put("h", hour);

		String hourstr = hour <= 9 ? "0" + hour: hour + "";
		hourstr = hourstr + ":00";
		System.out.println(hourstr);


		int index = -1;
		int count = 0;
		for (int i = 0; i < times.size(); i++) {
			String tmp  = times.get(i);
			if(hourstr.equals(tmp)) {
				index = i;
				break;
			}
			count++;
		}
		if(index==-1 && count > 0) {

			String startTimeStr =  year + "-" + month + "-" + day+ " "
					+ times.get(0)+ ":" + second;
			calendar.setTime(DateUtil.parseDate(startTimeStr));
			year = calendar.get(Calendar.YEAR);					//获取年份
			month = calendar.get(Calendar.MONTH) + 1;					//获取月份
			day = calendar.get(Calendar.DATE);					//获取日

			hour = calendar.get(Calendar.HOUR_OF_DAY);				//时（24小时制）
			minute = calendar.get(Calendar.MINUTE);					//分
			second = calendar.get(Calendar.SECOND);
			current.put("h", hour);
		}
		int i = 0;
		int lc = 0;
		while (current.get("a") < hours) {

			i = ss(current, times);
			int tmphour = 0;
			if(i == times.size() - 1) {
				tmphour = Integer.parseInt(times.get(0).split(":")[0]);
				lc++;

			}else {
				tmphour = Integer.parseInt(times.get(i).split(":")[0]);
				tmphour = tmphour + 1;
			}
			current.put("h", tmphour);
		}
		String endTimeStr =  year + "-" + month + "-" + day+ " "
		+ current.get("h") + ":" + minute + ":" + second;


		String afterNDay = DateUtil.afterNDay(DateUtil.parseDate(endTimeStr),lc);
//		System.out.println(current);
//		System.out.println(lc);
//		System.out.println(endTimeStr);
//		System.out.println(afterNDay);
		return afterNDay;

	}

	private static int ss(Map<String,Integer> current,List<String> times) {
		int j = 0;
		int hour = current.get("h");
		String hourstr = (hour < 10 ? ("0" + hour) : hour + "") + ":00";
		for (int i = 0; i < times.size(); i++) {
			String time = times.get(i);
			if(time.equals(hourstr)) {
				current.put("a", current.get("a") + 1);
//				System.out.println(i);
				return i;
			}
		}
		System.out.println("kkk");
		System.out.println(j);
		return j;
	}
	public static Date inTaskTime(Date date, List<String> times) {

		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);					//放入Date类型数据

		int year = calendar.get(Calendar.YEAR);					//获取年份
		int month = calendar.get(Calendar.MONTH) + 1;					//获取月份
		int day = calendar.get(Calendar.DATE);					//获取日

		int hour = calendar.get(Calendar.HOUR_OF_DAY);				//时（24小时制）
		int minute = calendar.get(Calendar.MINUTE);					//分
		int second = calendar.get(Calendar.SECOND);

		String hourstr = hour <= 9 ? "0" + hour: hour + "";

		if(times.indexOf(hourstr)!=-1) {
			return date;
		}

		return null;
	}
	public static String calcConfirmTime(Date startTime, List<String> times) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(startTime);					//放入Date类型数据

		int year = calendar.get(Calendar.YEAR);					//获取年份
		int month = calendar.get(Calendar.MONTH) + 1;					//获取月份
		int day = calendar.get(Calendar.DATE);					//获取日

		int hour = calendar.get(Calendar.HOUR_OF_DAY);				//时（24小时制）
		int minute = calendar.get(Calendar.MINUTE);					//分
		int second = calendar.get(Calendar.SECOND);

		String hourstr = (hour < 10 ? ("0" + hour) : hour + "") + ":00";
		int index = -1;
		int count = 0;
		for (int i = 0; i < times.size(); i++) {
			String tmp  = times.get(i);
			if(hourstr.equals(tmp)) {
				index = i;
				break;
			}
			count++;
		}
		if(index != -1) {
			if(index == times.size() - 1) {
				if(minute >= 30) {
					String current [] = times.get(0).split(":");

					hour = hour + 1;

					int minute2 = 60 - minute;
					minute = 30 - minute2;
					String timeStr =  year + "-" + month + "-" + day+ " "
							+ (current[0]) + ":" + minute + ":" + second;

					return afterNDay(parseDate(timeStr),1);
				}else {

				}

			}
			if(minute >= 30) {//例如：35;  60-35 = 25; 30- 25= 5;
				hour = hour + 1;

				int minute2 = 60 - minute;
				minute = 30 - minute2;
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ hour + ":" + minute + ":" + second;
				return timeStr;
			}else {
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ hour + ":" + (minute + 30) + ":" + second;
				return timeStr;
			}
		}else {
			if(count == times.size()) {
				String current [] = times.get(0).split(":");
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ (current[0]) + ":" + (Integer.parseInt(current[1]) + 30) + ":" + second;
				return afterNDay(parseDate(timeStr),1);
			}else {
				String current [] = times.get(count).split(":");
				System.out.println(current);
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ (current[0]) + ":" + (Integer.parseInt(current[1]) + 30) + ":" + second;
				return timeStr;
			}
		}

	}

	/**
	 * 新版本的待确认预警计算方式
	 * @param startTime
	 * @param times
	 * @return
	 */
	public static String calcConfirmTimeFor20Minute(Date startTime, List<String> times) {

		Calendar calendar = Calendar.getInstance();
		calendar.setTime(startTime);					//放入Date类型数据

		int year = calendar.get(Calendar.YEAR);					//获取年份
		int month = calendar.get(Calendar.MONTH) + 1;					//获取月份
		int day = calendar.get(Calendar.DATE);					//获取日

		int hour = calendar.get(Calendar.HOUR_OF_DAY);				//时（24小时制）
		int minute = calendar.get(Calendar.MINUTE);					//分
		int second = calendar.get(Calendar.SECOND);

		String hourstr = (hour < 10 ? ("0" + hour) : hour + "") + ":00";
		int index = -1;
		int count = 0;
		for (int i = 0; i < times.size(); i++) {
			String tmp  = times.get(i);
			if(hourstr.equals(tmp)) {
				index = i;
				break;
			}
			count++;
		}
		if(index != -1) {
			if(index == times.size() - 1) {
				if(minute >= 40) {
					String current [] = times.get(0).split(":");

					hour = hour + 1;

					int minute2 = 60 - minute;
					minute = 20 - minute2;
					String timeStr =  year + "-" + month + "-" + day+ " "
							+ (current[0]) + ":" + minute + ":" + second;

					return afterNDay(parseDate(timeStr),1);
				}else {

				}

			}
			if(minute >= 40) {//例如：45;  60-45 = 15; 20- 15= 5;
				hour = hour + 1;

				int minute2 = 60 - minute;
				minute = 20 - minute2;
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ hour + ":" + minute + ":" + second;
				return timeStr;
			}else {
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ hour + ":" + (minute + 20) + ":" + second;
				return timeStr;
			}
		}else {
			if(count == times.size()) {
				String current [] = times.get(0).split(":");
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ (current[0]) + ":" + (Integer.parseInt(current[1]) + 20) + ":" + second;
				return afterNDay(parseDate(timeStr),1);
			}else {
				String current [] = times.get(count).split(":");
				System.out.println(current);
				String timeStr =  year + "-" + month + "-" + day+ " "
						+ (current[0]) + ":" + (Integer.parseInt(current[1]) + 20) + ":" + second;
				return timeStr;
			}
		}
	}

	public static int findWorkTime(int hour,int minute,List<String> times) {
		int index = -1;
		for (int i = 0; i < times.size(); i++) {
			String time = times.get(i);
			String hour_tmp = time.split(":")[0];
			String minute_tmp = time.split(":")[1];
			//在区间
			if(Integer.parseInt(hour_tmp) == hour && minute  >= Integer.parseInt(minute_tmp) && minute <= 59) {
				index = i;
				break;
			}
		}
		return index;
	}

	public static List<String> getDays(String startTime, String endTime) {

        // 返回的日期集合
        List<String> days = new ArrayList<String>();

        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date start = dateFormat.parse(startTime);
            Date end = dateFormat.parse(endTime);

            Calendar tempStart = Calendar.getInstance();
            tempStart.setTime(start);

            Calendar tempEnd = Calendar.getInstance();
            tempEnd.setTime(end);
            tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
            while (tempStart.before(tempEnd)) {
                days.add(dateFormat.format(tempStart.getTime()));
                tempStart.add(Calendar.DAY_OF_YEAR, 1);
            }

        } catch (ParseException e) {
            e.printStackTrace();
        }

        return days;
    }

	public static int day(String dbtime1,String dbtime2) throws ParseException {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Date date1 = format.parse(dbtime1);
		Date date2 = format.parse(dbtime2);
		int a = (int) ((date1.getTime() - date2.getTime()) / (1000*3600*24));
		return a;
	}

	public static long getWorkLong (Date stopTime,Date endTime) {
		try {
			int d = DateUtil.day(DateUtil.formatDate(endTime,DateUtil.DatePattern.yyyy_MM_dd),
					DateUtil.formatDate(stopTime,DateUtil.DatePattern.yyyy_MM_dd));
			System.out.println(d);
			long total = 0;
			//2020-11-27 06:26:00 2020-11-27 14:26:00  2020-11-27 23:26:00
			long stop = DateUtil.parseDate(DateUtil.formatDate(stopTime,DateUtil.DatePattern.HHmmss),DateUtil.DatePattern.HHmmss).getTime();
			//2020-11-28 06:26:00 2020-11-28 07:26:00  2020-11-28 20:26:00 2020-11-28 23:26:00
			long end = DateUtil.parseDate(DateUtil.formatDate(endTime,DateUtil.DatePattern.HHmmss),DateUtil.DatePattern.HHmmss).getTime();
			String hhmmss1 = DateUtil.formatDate(stopTime,DateUtil.DatePattern.HHmmss);
			String hhmmss = DateUtil.formatDate(endTime,DateUtil.DatePattern.HHmmss);
			if(d > 0) {

				long time1 = 0;
				long time2 = 0;
				if(Integer.parseInt(hhmmss1.split(":")[0]) >= 7) {
					if(Integer.parseInt(hhmmss1.split(":")[0]) < 23) {
						time1 = DateUtil.parseDate("22:59:59",DateUtil.DatePattern.HHmmss).getTime() - stop;
					}
				}else {
					time1 = DateUtil.parseDate("22:59:59",DateUtil.DatePattern.HHmmss).getTime() - DateUtil.parseDate("07:00:00",DateUtil.DatePattern.HHmmss).getTime();
				}

				if(Integer.parseInt(hhmmss.split(":")[0]) >= 7) {
					if(Integer.parseInt(hhmmss.split(":")[0]) < 23) {
						time2 = end - DateUtil.parseDate("07:00:00",DateUtil.DatePattern.HHmmss).getTime();
					}else {
						time2 = DateUtil.parseDate("22:59:59",DateUtil.DatePattern.HHmmss).getTime() - DateUtil.parseDate("07:00:00",DateUtil.DatePattern.HHmmss).getTime();
					}
				}else {
					time2 = 0;
				}
				total = time1 + time2 + ((d - 1)*60*60*16*1000);
				return total;
			}else if(d == 0) {
				long time1 = 0;
				if(Integer.parseInt(hhmmss1.split(":")[0]) >= 7) {
					if(Integer.parseInt(hhmmss.split(":")[0]) < 23) {
						time1 = end - stop;
					}else {
						time1 = DateUtil.parseDate("22:59:59",DateUtil.DatePattern.HHmmss).getTime() - stop;
					}
				}else {
					if(Integer.parseInt(hhmmss.split(":")[0]) < 23) {
						time1 = end - DateUtil.parseDate("07:00:00",DateUtil.DatePattern.HHmmss).getTime();
					}else {
						time1 = DateUtil.parseDate("22:59:59",DateUtil.DatePattern.HHmmss).getTime() - DateUtil.parseDate("07:00:00",DateUtil.DatePattern.HHmmss).getTime();
					}
				}
				total = time1;
				return total;
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return 0;
	}

	public static String computeTime(long timestampDiff){
		long computeTime = timestampDiff / 1000;
		long year = (computeTime / 86400 / 365);
		computeTime = computeTime % (86400 * 365);
		long month = (computeTime / 86400 / 30);
		computeTime = computeTime % (86400 * 30);
		long day = (computeTime / 86400);
		computeTime = computeTime  % 86400;
		long hour = (computeTime / 3600);
		computeTime = computeTime  % 3600;
		long minute = (computeTime / 60);
		computeTime  = computeTime % 60;
		long second = computeTime ;
		return year+"年"+month+"月"+day+"天"+hour+"小时"+minute+"分"+second + "秒";
	}

	public static String computeTimeExt(long timestampDiff){
		long computeTime = timestampDiff / 1000;
		long hour = (computeTime / 3600);
		computeTime = computeTime  % 3600;
		long minute = (computeTime / 60);
		computeTime  = computeTime % 60;
		long second = computeTime ;
		return  hour+"小时"+minute+"分"+second + "秒";
	}
	public static long[] computeTimeArr(long timestampDiff){
		long arr[] = new long[3];
		long computeTime = timestampDiff / 1000;
		long hour = (computeTime / 3600);
		computeTime = computeTime  % 3600;
		long minute = (computeTime / 60);
		computeTime  = computeTime % 60;
		long second = computeTime ;
		arr[0] = hour;
		arr[1] = minute;
		arr[2] = second;
		return  arr;
	}

	/**
	 * 单位毫秒
	 * @param stopWorkLong
	 * @param warningConfirmTime
	 * @return
	 */
	public static Date ReCalcTaskTime(long stopWorkLong, Date warningConfirmTime) {
		long[] computeTimeArr = DateUtil.computeTimeArr(stopWorkLong);
		//小时
		long day = 0;
		long hour = computeTimeArr[0];
		long minute = computeTimeArr[1];
		long second = computeTimeArr[2];
		if(hour > 16) {
			day = hour / 16;
			hour = hour % 16;
		}
		//把天数先加上
		warningConfirmTime = DateUtil.addNDay(warningConfirmTime, Integer.parseInt(String.valueOf(day)));
		//秒
		for (int i = 0; i < second; i++) {
			warningConfirmTime = DateUtil.addNSecond(warningConfirmTime, 1);
		}

		//分钟
		for (int i = 0; i < minute; i++) {
			warningConfirmTime = DateUtil.addNMinute(warningConfirmTime, 1);
		}
		for (int i = 0; i < hour; i++) {
			String afterNHour = DateUtil.afterNHour(warningConfirmTime, 1);
			String hhmmss = afterNHour.split(" ")[1].replace(":", "");
			if(Integer.parseInt(hhmmss) >= 70000 && Integer.parseInt(hhmmss) <= 225959) {
				warningConfirmTime = DateUtil.addNHour(warningConfirmTime, 1);
			}else {
				warningConfirmTime = DateUtil.addNDay(warningConfirmTime, 1);
				Calendar calendar = Calendar.getInstance();
				calendar.setTime(warningConfirmTime);
				calendar.set(Calendar.HOUR_OF_DAY, 7);
				warningConfirmTime = calendar.getTime();
			}
		}


		return warningConfirmTime;
	}

	/**
	 * Calendar.MONDAY
	 * @param month
	 * @param num
	 * @param weekday
	 * @return
	 */
	public static String getNMonNMumNWeek(Date today,int month,int num,int weekday) {
		Calendar calendar=Calendar.getInstance();
		if(today!= null) {
			calendar.setTime(today);
		}
		calendar.set(Calendar.MONTH, month - 1);
        int days=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        List<String> daysList = new ArrayList<>();
        int n=0;
        for(int i=1;i<=days;i++){
            calendar.set(Calendar.DAY_OF_MONTH, i);
            if(calendar.get(Calendar.DAY_OF_WEEK)==weekday){
//                System.out.println(calendar.get(Calendar.YEAR)+"-"+(calendar.get(Calendar.MONTH)+1)+"-"+calendar.get(Calendar.DATE));
            	daysList.add(calendar.get(Calendar.YEAR)+"-"
            			+((calendar.get(Calendar.MONTH)+1) <10 ? ("0" + (calendar.get(Calendar.MONTH)+1)):(calendar.get(Calendar.MONTH)+1))+"-"
            			+((calendar.get(Calendar.DATE) < 10 ? ("0"+(calendar.get(Calendar.DATE))): calendar.get(Calendar.DATE))));
                n++;
            }
        }
        if(daysList.size() < num - 1) {
        	return null;
        }
//        System.out.println(n);
        return daysList.get(num - 1);
	}

	public static void main(String[] args) {
		List<String> times = Arrays.asList("15:00","16:00","17:00","18:00","19:00","20:00");
//		System.out.println(calcTaskTime(DateUtil.parseDate("2020-11-06 20:15:00"),times, 1));
//		System.out.println(calcTaskTime(DateUtil.parseDate("2020-11-06 20:35:00"),times, 5));
//		System.out.println(calcTaskTime(DateUtil.parseDate("2020-11-06 20:59:00"),times, 3));
		// 17:15-18:15  18:15-19:15 19:15-20:00 15:00-15:15 15:15-16:15 16:15-17:15
//		System.out.println(calcConfirmTime(DateUtil.parseDate("2020-11-09 17:40:00"), times));
//		System.out.println(yearMonthAddZero("2020-1-1"));
//		System.out.println(calcConfirmTimeFor20Minute(DateUtil.parseDate("2020-11-09 17:41:00"), times));
//		System.out.println(DateUtil.parseDate(calcConfirmTimeFor20Minute(DateUtil.parseDate("2020-11-09 20:41:00"), times)));

//		for (int i = 0; i < 3600; i++) {
//			int a = i;
//			System.out.println(a);
//		}
//		try {
//			System.out.println(day("2020-11-28","2020-11-27"));
//		} catch (ParseException e) {
//			e.printStackTrace();
//		}

//		long time = getWorkLong(DateUtil.parseDate("2020-11-27 14:48:22"), DateUtil.parseDate("2020-11-27 23:02:01"));
//		long time = getWorkLong(DateUtil.parseDate("2020-11-27 04:48:22"), DateUtil.parseDate("2020-11-27 23:02:01"));
//		long time = getWorkLong(DateUtil.parseDate("2020-11-27 04:48:22"), DateUtil.parseDate("2020-11-28 03:02:01"));
//		long time = getWorkLong(DateUtil.parseDate("2020-11-27 13:48:22"), DateUtil.parseDate("2020-11-29 03:02:01"));
//		long time = getWorkLong(DateUtil.parseDate("2020-11-27 04:48:22"), DateUtil.parseDate("2020-11-28 20:02:01"));
//		System.out.println(time);
//		System.out.println(computeTimeExt(time));
//		Date time = ReCalcTaskTime(60*60*7*1000 + 1000*1, DateUtil.parseDate("2020-11-27 16:08:01"));
//		System.out.println(DateUtil.formatDate(time));

//		Date time = ReCalcTaskTime(60*60*7*1000 + 1000*60*52, DateUtil.parseDate("2020-11-27 06:08:01"));
//		System.out.println(DateUtil.formatDate(time));

		System.out.println(getNMonNMumNWeek(null, 1, 1, Calendar.TUESDAY));
	}
}
